class Solution
{
public:
    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int> &colsum)
    {
        int n = colsum.size();
        vector<vector<int>> result(2, vector<int>(n, 0));
        for (int i = 0; i < n; ++i)
        {
            if (colsum[i] == 1)
            {
                continue;
            }
            if (colsum[i] == 2)
            {
                result[0][i] = 1;
                result[1][i] = 1;
                --upper;
                --lower;
            }
            colsum[i] = -1;
        }
        for (int i = 0; i < n; ++i)
        {
            if (colsum[i] != -1)
            {
                if (upper > 0)
                {
                    result[0][i] = 1;
                    --upper;
                }
                else
                {
                    result[1][i] = 1;
                    --lower;
                }
            }
        }
        if (lower != 0 || upper != 0)
        {
            return {};
        }
        return result;
    }
};